<?php

if (!defined('BASEPATH'))
    exit('No direct script access allowed');

class Scheduled_Job extends CI_Controller {

    public function __construct() {
        parent::__construct();
        $this->load->helper('url');
        $this->load->model('setting_model');
        $this->load->model('user_model');
    }

    public function index() {
        
    }
    
    public function give_freeroll() {
        $styles = array(
            'js/bootstrap/dist/css/bootstrap.css',
            'fonts/font-awesome-4/css/font-awesome.min.css',
            'js/jquery.gritter/css/jquery.gritter.css',
            'js/jquery.nanoscroller/nanoscroller.css',
            'js/jquery.easypiechart/jquery.easy-pie-chart.css',
            'js/bootstrap.switch/bootstrap-switch.css',
            'js/bootstrap.datetimepicker/css/bootstrap-datetimepicker.min.css',
            'js/jquery.select2/select2.css',
            'js/bootstrap.slider/css/slider.css',
            'js/intro.js/introjs.css',
            'css/style.css',
            'css/ts-style.css',
        );
        $scripts = array(
            'js/jquery.js',
            'js/jquery.gritter/js/jquery.gritter.js',
            'js/jquery.nanoscroller/jquery.nanoscroller.js',
            'js/behaviour/general.js',
            'js/jquery.ui/jquery-ui.js',
            'js/jquery.sparkline/jquery.sparkline.min.js',
            'js/jquery.easypiechart/jquery.easy-pie-chart.js',
            'js/jquery.nestable/jquery.nestable.js',
            'js/bootstrap.switch/bootstrap-switch.min.js',
            'js/bootstrap.datetimepicker/js/bootstrap-datetimepicker.min.js',
            'js/jquery.select2/select2.min.js',
            'js/skycons/skycons.js',
            'js/bootstrap.slider/js/bootstrap-slider.js',
            'js/intro.js/intro.js',
            'https://maps.googleapis.com/maps/api/js?v=3.exp&amp;sensor=false',
            'js/page/index.js',
            'js/behaviour/voice-commands.js',
            'js/bootstrap/dist/js/bootstrap.min.js',
            'js/jquery.flot/jquery.flot.js',
            'js/jquery.flot/jquery.flot.pie.js',
            'js/jquery.flot/jquery.flot.resize.js',
            'js/jquery.flot/jquery.flot.labels.js',
        );
        
        
        
        
        
        
        
        // get setting model
        $freeroll_hand = $this->setting_model->get_value('freeroll_hand');
        if (empty($freeroll_hand)) {
            $freeroll_hand = 1;
        }
        $freeroll_hand_list_line = $this->setting_model->get_value('freeroll_hand_list_line');
        if (empty($freeroll_hand_list_line)) {
            $freeroll_hand_list_line = 0;
        }
        $freeroll_hand_line = $this->setting_model->get_value('freeroll_hand_line');
        if (empty($freeroll_hand_line)) {
            $freeroll_hand_line = 0;
        }
        
        $response = array();
        $response[count($response)] = Api::system_get("LoginChime");
        /*
        // track to history list
        $history_list = Api::logs_hand_history_list();
        for ($index = $freeroll_hand_list_line; $index < $history_list->Files; $index++) {
            $response[count($response)] = 1111;
            // track to line reading
            $file = Api::logs_hand_history($history_list->Date[$index], $history_list->Name[$index]);
            $line_num = count($file->Data);
            for ($line_index = $freeroll_hand_line; $line_index < $line_num; $line_index++) {
                
                // analize the where the "Seat"
                $line = $file->Data[$line_index];
                if (String_util::startsWith($line, "Seat ")) {
                    $playerName = String_util::parsePlayerName($line);
                    // increase hand of user
                    $hand_number = $this->user_model->increase_hand_number($playerName);
                    if ($hand_number % $freeroll_hand === 0) {
                        // have a freeroll
//                        $response[count($response)] = $playerName;
//                        $response[count($response)] = Api::system_entry_fee_get($playerName);
                        break;
                    }
                }
                
            }
        }*/
        // set setting model
//        $this->setting_model->set_value($freeroll_hand_list_line,$history_list->Files - 1);
//        $this->setting_model->set_value($freeroll_hand_line,$line_num - 1);
        
        $data = array(
            'assets' => base_url() . 'assets',
            'title' => 'Index',
            'user_info' => $this->session->userdata('user_info'),
            'styles' => $styles,
            'scripts' => $scripts,
            'response' => $response,
        );

        $this->load->view('include/header', $data);
        $this->load->view('scheduled_job/give_freeroll', $data);
        $this->load->view('include/footer', $data);
        
    }

}

/* End of file home.php */
/* Location: ./application/controllers/home.php */